﻿import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import "logic.js" as LOGIC

Window {
    id:mainWindow
    property alias stackView: stackView

    width: 640
    height: 480
    minimumHeight: 480
    minimumWidth: 540
    color: "#FFFFFF"
    visible: true
    title: qsTr("mineSweep")

    StackView{
        id:stackView
        anchors.fill: parent
        initialItem: selectLevel
    }
    Item{
        id:selectLevel
        visible: true
//        anchors.fill: parent
        anchors.margins: 20
        Rectangle{
            width:parent.width<parent.height?parent.width:parent.height
            height:width
            color: "#FFFFFF"
            anchors.centerIn: parent
            Grid{
                anchors.fill: parent
                anchors.margins: 20
                spacing: 20
                rows: 2
                Rectangle{
                    id:easyRect
                    x:40;y:40
                    width:parent.width/2-10
                    height:width
                    color: "#E0E0E0"
                    Rectangle{
                        width:parent.width/9
                        height:parent.height/9
                        color: "#E0E0E0"
                        anchors.centerIn: parent
                        Row{
                            anchors.fill: parent
                            Text {
                                text: "8x8"
                                anchors{
                                    top:parent.top;horizontalCenter:parent.horizontalCenter
                                }
                                font.pixelSize: parent.height*0.6
                                font.bold: true
                            }
                            Text{
                                text: qsTr("10 mines")
                                anchors{
                                    bottom: parent.bottom; horizontalCenter: parent.horizontalCenter}
                                font.pixelSize: parent.height*0.4
                            }
                        }

                    }
                    MouseArea{
                        anchors.fill: parent
                        onClicked:{
                            LOGIC.createGameScene(8,8,10);
                        }
                    }
                }
                Rectangle{
                    width:parent.width/2-10
                    height:width
                    color: "#E0E0E0"
                    Rectangle{
                        width:parent.width/9
                        height:parent.height/9
                        color: "#E0E0E0"
                        anchors.centerIn: parent
                        Row{
                            anchors.fill: parent
                            Text {
                                text: "16x16"
                                anchors{
                                    top:parent.top;horizontalCenter:parent.horizontalCenter
                                }
                                font.pixelSize: parent.height*0.6
                                font.bold: true
                            }
                            Text{
                                text: qsTr("40 mines")
                                anchors{
                                    bottom: parent.bottom; horizontalCenter: parent.horizontalCenter}
                                font.pixelSize: parent.height*0.4
                            }
                        }
                    }
                    MouseArea{
                        anchors.fill: parent
                        onClicked:{
                            LOGIC.createGameScene(16,16,40);
                        }
                    }
                }
                Rectangle{
                    width:parent.width/2-10
                    height:width
                    color: "#E0E0E0"
                    Rectangle{
                        width:parent.width/9
                        height:parent.height/9
                        color: "#E0E0E0"
                        anchors.centerIn: parent
                        Row{
                            anchors.fill: parent
                            Text {
                                text: "30x16"
                                anchors{
                                    top:parent.top;horizontalCenter:parent.horizontalCenter
                                }
                                font.pixelSize: parent.height*0.6
                                font.bold: true
                            }
                            Text{
                                text: qsTr("99 mines")
                                anchors{
                                    bottom: parent.bottom; horizontalCenter: parent.horizontalCenter}
                                font.pixelSize: parent.height*0.4
                            }
                        }
                    }
                    MouseArea{
                        anchors.fill: parent
                        onClicked:{
                            LOGIC.createGameScene(16,30,99);
                        }
                    }
                }
                Rectangle{
                    width:parent.width/2-10
                    height:width
                    color: "#E0E0E0"
                    Rectangle{
                        width:parent.width/9
                        height:parent.height/9
                        color: "#E0E0E0"
                        anchors.centerIn: parent
                        Row{
                            anchors.fill: parent
                            Text {
                                text: "?"
                                anchors{
                                    top:parent.top;horizontalCenter:parent.horizontalCenter
                                }
                                font.pixelSize: parent.height*0.6
                                font.bold: true
                            }
                            Text{
                                text: qsTr("Self Defined")
                                anchors{
                                    bottom: parent.bottom; horizontalCenter: parent.horizontalCenter}
                                font.pixelSize: parent.height*0.4
                            }
                        }
                    }
                }
            }
        }
    }
}
